package com.jackson.springencdec.controller;

/*
 * Author: JacksonCoder
 * FileName: RsaController
 * Version: 1.0.0
 * Date: 2025-10-15
 */

import com.jackson.springencdec.config.RSAConfig;
import com.jackson.springencdec.utils.RSAUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/rsa")
public class RsaController {

    @Autowired
    private RSAConfig rsaConfig;

    @RequestMapping("/getPwd")
    public String getDecryptPwd() throws Exception {
        String data = "123456789";
        byte[] bytes = RSAUtils.encryptByPublicKey(data, rsaConfig.getPublicKey());
        String enCryptPwd = RSAUtils.encryptBASE64(bytes);
        return enCryptPwd;
    }

}
